<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>主题机会</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">				
			p {margin:3px;}
			ul {margin:5px;}
			//li {margin-bottom:2px;}		
			.fixedBox{
				border: 1px solid #555555;				
				white-space: nowrap;	
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}
			img,a img{
				border:0;
				margin:0;
				padding:0;
				max-width:400px;
				width:e-xpression(this.width>400?"400px":this.width);
				//max-height:100px;
				//height:e-xpression(this.height>100?"100px":this.height);
			}
		</style>		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script>
			window.onload = function() {
			getSource("1");
			changeStyle();
			}
						
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					getSource("");					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {
				time_range("9:00","15:15")						
				},
				60000);
			})
			
			function changeStyle() {
				var obj1 = document.getElementById("towrite");				
				obj1.style.left= "0px"; 				
				obj1.style.width= "480px";	
				obj1.style.height= "620px";		
				obj1.style.fontSize="12px";	
				
				var obj2 = document.getElementById("inform");
				obj2.style.display = "none";
				obj2.style.whiteSpace = "normal"; 			
				obj2.style.left= "0px"; 				
				<!-- obj1.style.width= "480px";	 -->
				<!-- obj1.style.height= "620px";		 -->
				<!-- obj1.style.fontSize="12px";					 -->
			}
			
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};

			function getLocalTime(nS) {			          
			return new Date(parseInt(nS*1000)).Format("yyyy-MM-dd")}

			function createXmlHttp() {
				if (window.XMLHttpRequest) {
				xmlHttp = new XMLHttpRequest();
				} else {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}
			
			function changeCss(obj,id){				
				var alist = document.getElementById(id).getElementsByTagName("a");					
				for(var i = 0; i < alist.length; i++){				
					if(alist[i] == undefined){
						break;
					}
					alist[i].style.color = "#E5E5E5"; //给所有a标签赋原色
					if(alist[i].id == "Title"){
						alist[i].style.color = "#FFFFFF";
					}
					
				}
				obj.style.color = "#00FFFF"; //令当前标签高亮				
			}
			
			var p = "1";
			function getSource(ss) {			
				var pz = "<a href='javascript:void(0)' id='bt1' onclick='getSource(" + "\"1\"" + ")'>" + "最新主题" + "</a>";
				var ph = "<a href='javascript:void(0)' id='bt2' onclick='getSource(" + "\"2\"" + ")'>" + "潜伏主题" + "</a>";	
				div1 = document.getElementById('towrite');
				var top = '<a href="javascript:Top();" style="position:fixed; left:450px; color:#fff; font-size:16px;">Top</a>' 
				div1.innerHTML = top + '<h4>主题机会（' + pz + "&nbsp;&nbsp;&nbsp;&nbsp;" + ph + '）</h4>';
				if(ss != ""){
					p = ss;
				}
				aObj = document.getElementById('bt' + p);				
				aObj.style.color = "#FFA07A";
				
				var url1 = "https://apparticle.longhuvip.com/w1/api/index.php?apiv=w28&c=ThemeNews&a=GetList&Type=-1&st=30"; 
				var url2 = "https://apparticle.longhuvip.com/w1/api/index.php?apiv=w28&c=ThemeNews&a=GetList&Type=2&st=20"
				var url = url1;
				if(p == "2"){
					url = url2;
				}				
				createXmlHttp();
				xmlHttp.onreadystatechange = writeSource;
				xmlHttp.open("GET", url, true);
				xmlHttp.send(null);
			}
			
			function Top(){
				document.getElementsByClassName('fixedBox')[0].scrollTop = 0;
			}
			
			var cid = "";
			function writeSource() { 
				if (xmlHttp.readyState == 4) {         
					var data = xmlHttp.responseText													
					//document.write(data);

					var transform_aa = [           
					{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
					];
					
					var transform_bb= 
					{"tag":"p", children:[
					{"tag": "b style ='color:#FFD700'", "html": function(){
						if(this.ZSName){
							return(this.ZSName + this.Kword + "&nbsp;&nbsp;" + getLocalTime(this.TimeStamp));
						}
					}},				
					//{"tag": "p", "html":"<b style ='color:#FFFFFF;white-space:normal;'> ${Title}</b>"},
					{"tag": "b", "html": function(){
						cid = this.CID;
						return("<a href='javascript:void(0)' style='color:#FFFFFF;white-space:normal;' id='Title' onclick='showInform(" + cid + ");changeCss(this,\"gg\")'>" + this.Title + "</a>");					
					}},						
					{"tag": "ul style ='color:#FFD700'", "html": function(){
						if(this.EvnTime){
							return("事件时间：" + this.EvnTime);
						}
					}},							
					{"tag":"ul", children:function(){return(json2html.transform(this.Stocks, transform_cc));}}
					]};
					
					var transform_cc= 				
					{"tag":"ul", children:[							
					{"tag": "li", "html":"<a href='dzh://VIEWSTOCK?PAGE=分时走势&LABEL=${Code}' onclick='changeCss(this,\"gg\")'>${Code} ${Name} &nbsp;&nbsp;涨幅：${Rate}% </a>"}, 							
					]};  
					

					var html = json2html.transform(data, transform_aa);		
					div = document.getElementById('towrite');
					div.innerHTML += "<span id='gg'>" + html;
				}
			}
			
			function showInform(s){
				//alert(s)			
				//var x = event.clientX; 
				//var y = event.clientY;
				
				
				div = document.getElementById("inform");
				div.style.position = "absolute"; 
				//div.style.top = (y - 10) + "px";
				div.style.top = 100 + "px";
				div.style.width = "450px"; 
				div.style.maxHeight = "400px"; /* 设置最大高度，当高度达到此值时出现滚动条 */ 
				div.style.zIndex  = "10"; 			
				div.style.overflow = "auto"; /* 自动添加滚动条 */ 
				div.style.boxShadow ="0px 0px 10px #D3D3D3"; /* 外阴影 */ 
				div.style.backgroundColor = "#696969"; 
				//div.style.color = "#FFE4E1";
				//div.style.color = "#FFD700";				
				div.style.fontSize = "14px";				 				
				//div.style.display = "none"; /* 默认隐藏 */ 
				div.style.display = 'block';												
				
				update(s);
				
				//回到顶部					
				document.getElementsByClassName('fixedBox')[1].scrollTop = 0;
			} 
			
			function update(ss) {
				var url1 = "https://apparticle.longhuvip.com/w1/api/index.php?apiv=w28&c=ThemeNews&a=GetInfo&NewsID=" + ss; 
				var url2 = "https://apparticle.longhuvip.com/w1/api/index.php?apiv=w28&c=ThemeNews&a=GetInfo&Type=2&NewsID=" + ss;
				var url = url1;
				if(p == "2"){
					url = url2;
				}
				
				if (window.XMLHttpRequest) {
					xmlHttp = new XMLHttpRequest();
				} else {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				xmlHttp.onreadystatechange = writeSource1;
				xmlHttp.open("GET", url, true);
				xmlHttp.send(null);
			}
			
			function writeSource1() { 
				if (xmlHttp.readyState == 4) {         
					var data = xmlHttp.responseText
					//data = data.replace(/\<\\\/\p>/g,"").replace(/\r\n/g,"");
					//document.write(data);
					
					var transform_aa = [           
					{"tag":"ul", children:function(){return(json2html.transform(this.Info, transform_bb));}}
					];
					
					var transform_bb= 
					{"tag":"p", children:[					
					{"tag": "b style ='color:#FFFFFF;'", "html":"${Title}"},	
					{"tag": "p", "html": function(){
						if(this.TimeStamp){
							return(getLocalTime(this.TimeStamp));
						}
					}},	
					{"tag": "ul style ='color:#FFD700;'", "html":"${Content}"},	
					{"tag": "p", "html":"<br>关联板块：${ZSName}"},	
					{"tag": "p", "html":"关联个股："},						
					{"tag":"ul", children:function(){return(json2html.transform(this.Stocks, transform_cc));}}
					]};
					
					var transform_cc= 				
					{"tag":"ul", children:[							
					{"tag": "li", "html":"<a  style ='color:#FFFFFF;' href='dzh://VIEWSTOCK?PAGE=分时走势&LABEL=${Code}' >${Code} ${Name} &nbsp;&nbsp;涨幅：${Rate}% </a>"}, 
					{"tag": "p style ='color:#FFD700;'", "html":"${Desn}"},					
					]};  
					
					var html = json2html.transform(data, transform_aa);						
					html = html.replace(/rgb\(0, 0, 0\)/g,"rgb(255, 255, 255)").replace(/rgb\(255, 0, 0\)/g,"rgb(225, 255, 255)").replace(/color:#FFD700/g,"color:#FAFAD2");					
					div = document.getElementById('inform');					
					div.innerHTML = '<a href="javascript:close();" style="position:fixed; left:400px; color:#fff">关闭</a>' + html;	
				}
			}
			
			function close() { 
				var div = document.getElementById("inform");						
				div.style.display = "none";
			}
			
		</script>
	</head>
	<body>
		<div id="towrite" class="fixedBox"></div>
		<div id="inform"  class="fixedBox"></div>
	</body>
</html>